package com.skyline.spot.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.skyline.base.type.RatyObjType;
import com.skyline.spot.dao.RatyDao;
import com.skyline.spot.dao.SpotDao;
import com.skyline.spot.service.RatyService;

@Service("ratyService")
public class RatyServiceImpl implements RatyService {

	@Autowired
	private RatyDao ratyDao;
	@Autowired
	private SpotDao spotDao;

	@Override
	public void raty(Long objId, RatyObjType type, Long userId, Integer ratyStar) {
		ratyDao.raty(objId, type, userId, ratyStar);
	}

	@Override
	public boolean isRaty(Long objId, Long userId) {

		return ratyDao.isRaty(objId, userId);
	}

	@Override
	public Object ratyStar(Long objId, RatyObjType type, Long userId,
			Integer ratyStar) {
		if(type==RatyObjType.SPOT){
			ratyDao.raty(objId, type, userId, ratyStar);
			return spotDao.updateSpotStar(objId, ratyStar);
		}
			
		return null;
	}

}
